package com.webridge.plm.util;

import java.util.ArrayList;
import java.util.List;

import com.ptc.wpcfg.utilities.PrincipalHelper;

import wt.inf.container.WTContainer;
import wt.inf.team.ContainerTeam;
import wt.inf.team.ContainerTeamHelper;
import wt.inf.team.ContainerTeamManaged;
import wt.org.WTPrincipal;
import wt.org.WTPrincipalReference;
import wt.project.Role;
import wt.util.WTException;

public class TeamHelper {

    public static void removeRoleTest(String prdName,String roleName){
        try {
            WTContainer product = WCUtil.getWtContainerByName(prdName);
            Role role = Role.toRole(roleName);
            System.out.println("PRD Name:" + prdName+",role name:" + roleName);
            ContainerTeamManaged ctm = (ContainerTeamManaged) product;
            ContainerTeam ct = ContainerTeamHelper.service.getContainerTeam(ctm);
            System.out.println("start to remove role...");
            WTPrincipalReference user = PrincipalHelper.getPrincipal("supplier");
            WTPrincipalReference user1 = PrincipalHelper.getPrincipal("Administrator");
            WTPrincipalReference user2 = PrincipalHelper.getPrincipal("kira");
            WTPrincipalReference user3 = PrincipalHelper.getPrincipal("test1");
            List<WTPrincipal>list = new ArrayList<WTPrincipal>();
            list.add(user.getPrincipal());
            list.add(user1.getPrincipal());
            list.add(user2.getPrincipal());
            list.add(user3.getPrincipal());
            ContainerTeamHelper.service.addMembers(ct, role, list);
            
            
            ContainerTeamHelper.service.removeMembers(ct, role, list);
            System.out.println("remove role success.");
        } catch (WTException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
    }
}
